<template>
	<view style="height: 320rpx;" class="w-100 d-flex j-center a-center position-relative">
		<image src="/static/mine-bg.png" class="h-100 w-100 position-absolute left-0 top-0 right-0 bottom-0"
			mode="scaleToFill"></image>
		<view style="width:300rpx; z-index: 100;" class="d-flex flex-column a-center">
			<image :src="authStore.user.avatar || '/static/avatar.jpeg'" class="rounded-circle" style="width: 100rpx; height: 100rpx;" />
			<view class="text-white fs-24 mt-2">{{authStore.user.username}}</view>
		</view>
	</view>
	<uni-section title="显示右侧箭头" type="line">
		<uni-list>
			<uni-list-item showArrow title="修改信息" to="/pages/userinfo/userinfo" />
			<uni-list-item showArrow title="我的地址" rightText="右侧文字" to="/pages/address/address"/>
		</uni-list>
	</uni-section>
	<button type="warn" plain class="mt-4 mx-2" @click="onExit">退出登陆</button>
</template>

<script setup>
import { ref } from 'vue'
import  useAuthStore  from '@/stores/auth.js'
import userHttp from '@/apis/user/userHttp.js'
import { onShow } from "@dcloudio/uni-app"
import aliossHttp from '@/apis/auth/aliossHttp.js'

const authStore = useAuthStore()
console.log(authStore.user.avatar);
const onExit = async () => {
	
	await userHttp.logout()
	console.log('发送了请求');
	authStore.clearUserToken();
	console.log('清除了token');
	uni.switchTab({
		url: "/pages/index/index"
	})
	
}
onShow(()=>{
  if (!authStore.is_logined) {
    uni.redirectTo({
      url: '/pages/login/login'
    })
  }
}) 
</script>

<style></style>
